﻿
using SBlogCore.Entitys.SystemManager;
using SBlogCore.Entitys.SysUserManager;
using SBlogCore.WebAdminApplication.SysManager.Dto;

namespace SBlogCore.WebAdminApplication.SysUserManager.Dto
{
     public class SysUserInfoOutPut
    {
        /// <summary>
        /// 用户ID
        /// </summary>
        public long? Id { get; set; }
        /// <summary>
        /// 用户名字
        /// </summary>
        public string? UserName { get; set; }
        /// <summary>
        /// 用户年龄
        /// </summary>
        public int? Age { get; set; }
        /// <summary>
        /// 用户年龄
        /// </summary>
        public int? Sex { get; set; }
        /// <summary>
        /// 账号
        /// </summary>
        public string? Account { get; set; }
        /// <summary>
        /// 密码
        /// </summary>
        public string? PassWord { get; set; }
        /// <summary>
        /// 电话
        /// </summary>
        public string? Phone { get; set; }
        /// <summary>
        /// 邮箱
        /// </summary>
        public string? Email { get; set; }
        /// <summary>
        /// 角色集
        /// </summary>
        public string[]? Roles { get; set; }
        /// <summary>
        /// 照片地址
        /// </summary>

        public string? PhotoPath { get; set; }

        public string? OrgName { get; set; }
        public long? SysOrgId { get; set; }
    }
     public class SysUserInfoMaps : ISblogCoreMap
     {
         public void MapDo()
         {
             TypeAdapterConfig<SysUserInfo, SysUserInfoOutPut>.NewConfig()
                 .Map(d => d.PhotoPath, s => PhotoPathConfig(s))
                 .Map(d=>d.OrgName,s=>OrgNameConfig(s))
                 .Map(d=>d.SysOrgId, s=> SysOrgIdConfig(s));
         }

         private static string OrgNameConfig(SysUserInfo s)
         {
             return s.SysOrgInfo?.Name??string.Empty;
        }

         private static long? SysOrgIdConfig(SysUserInfo s)
         {
             return s.SysOrgInfo?.Id;
         }

        private static string PhotoPathConfig(SysUserInfo src)
         {
             return $"{src.SysFileMap?.SysFileInfo?.FileBucket}{src.SysFileMap?.SysFileInfo?.FilePath?.Replace('\\', '/')}";
         }
     }
}
